import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

var state={
    myindexshow:false,
    goodbookshow:false,
    nearShow:false,
    indexShow:true,
    bookArticle:false,
    cityShow:false,
    lifeShow:false,
    lifeArticleShow:false,
    shareShow:false
    };

const mutations={
    openShow:(state,txt)=>{
        if(txt=='my'){
            state.myindexshow=true;
        }else if(txt=='good'){
            state.goodbookshow=true;
        }else if(txt=='near'){
            state.nearShow=true;
            state.indexShow=false;
        }else if(txt=='index'){
            state.nearShow=false;
            state.indexShow=true;
        }else if(txt=='bookArticle'){
            state.goodbookshow=false;
            state.bookArticle=true;
        }else if(txt=='city'){
            state.cityShow=true;
        }else if(txt=='life'){
            state.lifeShow=true;
        }else if(txt=='lifeArticle'){
            state.lifeShow=false;
            state.lifeArticleShow=true;
        }else if(txt=='share'){
            state.shareShow=true;
        }

    },
    closeShow:(state,txt)=>{
        if(txt=='my'){
            state.myindexshow=false;
        }else if(txt=='good'){
            state.goodbookshow=false;
        }else if(txt=='index'){
            state.indexShow=false;
        }else if(txt=='bookArticle'){
            state.bookArticle=false;
            state.goodbookshow=true;
        }else if(txt=='city'){
            state.cityShow=false;
            state.indexShow=true;
        }else if(txt=='life'){
            state.lifeShow=false;
            state.indexShow=true;
        }else if(txt=='lifeArticle'){
            state.lifeArticleShow=false;
            state.lifeShow=true;
        }else if(txt=='share'){
            state.shareShow=false;
        }
    }

    }

const actions={
    openShow:({commit},txt)=>{
        commit('openShow',txt);
    },
    closeShow:({commit},txt)=>{
        commit('closeShow',txt);
    }
    }

export const store=new Vuex.Store({
    state,
    mutations,
    actions
});